﻿if (typeof (window['mocKinect']) == 'undefined') {
    (function (window, undefined) {
        var mocKinect = new function () {

            this.mockingSurface;
            this.InitKinect = function (useSkeletonTracking, eventModel) {
                jKinect_Callback("OnKinectReady");
            };
            this.Bind = function (eventName, jsHandler) {
                if (eventName == "HandPosition") {
                    document.onmousemove = function (e) {
                        $("#debugHand").html(e.pageX + "  " + e.pageY);
                        if (this.mockingSurface != undefined
                            && e.pageX > $(this.mockingSurface).position().left && e.pageX < $(this.mockingSurface).position().left + $(this.mockingSurface).width()
                            && e.pageY > $(this.mockingSurface).position().top && e.pageY < $(this.mockingSurface).position().top + $(this.mockingSurface).height()) {
                            var position = {};
                            position.X = e.pageX;
                            position.Y = e.pageY;
                            jsHandler(position);
                        }
                    }
                }
            };
            this.Unbind = function (eventName) {
            };
            this.GetNextSkeletonFrame = function () {
                if (jKinect.handlers["HandPosition"] != undefined) {

                }

                if (jKinect.handlers["SkeletonFrameReady"] != undefined
                || jKinect.handlers["SkeletonFrameReadyCenteredScaled"] != undefined
                || jKinect.handlers["SkeletonFrameReadyScaled"] != undefined) {
                    var skeleton = ({ "HipCenter": { "X": 0.50390625, "Y": 0.51875, "Z": -0.05028224 }, "Spine": { "X": 0.5, "Y": 0.5, "Z": 0.0 }, "ShoulderCenter": { "X": 0.503125, "Y": 0.401041657, "Z": 0.0531765223 }, "Head": { "X": 0.5125, "Y": 0.345833331, "Z": 0.06657338 }, "ShoulderLeft": { "X": 0.467968762, "Y": 0.430208325, "Z": -0.04766941 }, "ElbowLeft": { "X": 0.4421875, "Y": 0.5052083, "Z": -0.135161042 }, "WristLeft": { "X": 0.4421875, "Y": 0.571875, "Z": -0.245512128 }, "HandLeft": { "X": 0.4421875, "Y": 0.6010417, "Z": -0.280671239 }, "ShoulderRight": { "X": 0.538281262, "Y": 0.433333337, "Z": 0.1576209 }, "ElbowRight": { "X": 0.5453125, "Y": 0.498958319, "Z": 0.184976339 }, "WristRight": { "X": 0.559375, "Y": 0.545833349, "Z": 0.0477638245 }, "HandRight": { "X": 0.5671875, "Y": 0.546875, "Z": 0.00640010834 }, "HipLeft": { "X": 0.486718744, "Y": 0.5416667, "Z": -0.115348339 }, "KneeLeft": { "X": 0.469531238, "Y": 0.6625, "Z": -0.145758986 }, "AnkleLeft": { "X": 0.453125, "Y": 0.778125, "Z": -0.186298609 }, "FootLeft": { "X": 0.45625, "Y": 0.810416639, "Z": -0.2628553 }, "HipRight": { "X": 0.5203125, "Y": 0.540625, "Z": -0.0285929441 }, "KneeRight": { "X": 0.5125, "Y": 0.657291651, "Z": -0.05898428 }, "AnkleRight": { "X": 0.5046875, "Y": 0.767708361, "Z": -0.0995065 }, "FootRight": { "X": 0.51171875, "Y": 0.795833349, "Z": -0.174875855} });
                }
            };

            this.GetVersion = function () {
                return "jKinect with MocKinect";
            }

            this.accelerometerGetCurrentReading = function () {
                return "0, 0, 0";
            }

        }

        window.mocKinect = mocKinect;
    })(window);
}